<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<style type="text/css">
    .modal-backdrop.in{
        display: none;
        opacity: 0;
    }
	</style>
	<link rel="/admin/public/HiAdmin/shortcut icon" href="favicon.ico">
    <link href="__ROOT__/Public/Admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/css/animate.css" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/js/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/css/edit.css" rel="stylesheet"/>
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-10">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form class="form-horizontal m-t js-ajax-forms" id="cateForm" action="{:U('')}<if condition="$update">&type=update<else />&type=add</if> " method="post" enctype="multipart/form-data">
                            <if condition="isset($_GET['id'])">
	                            <div class="form-group row">
	                                <label class="col-sm-3 control-label">父部门</label>
	                                <div class="col-sm-8">
	                                    <input type="hidden" name="ParentID" value="<if condition="$update">{$data['Pid']}<else />{$_GET['id']}</if>">
										<if condition="$update"><input type="hidden" name="ID"  value="{$data['ID']}">
										<select class="form-control m-b" name="ParentID"  style="margin-bottom: 0px;">
											<option value="0"></option>
                                    		{$select_categorys}
                                		</select><else />
										<input class="form-control" readonly type="text" aria-required="true" aria-invalid="true" class="error" value="{$PName}">	
										</if>
	                                    
	                                    
	                                </div>
	                            </div>
                            </if>
                            
                            
                            <div class="form-group row">
                                <label class="col-sm-3 control-label">部门/子公司名称 *</label>
                                <div class="col-sm-8">
                                    <input id="Name" name="Name" class="form-control" type="text" aria-required="true" aria-invalid="true" class="error" value="{$data['Name']}">
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-3 control-label">负责人</label>
                                <div class="col-sm-8">
                                    <input id='BossID' name='BossID' value="{$data.BossID}" type="hidden">
                                    <input id="BossName" name="BossName" class="form-control selector-icon"  onclick="openselector('BossID','BossName')" data-toggle="modal" data-target="#myModal" type="text"  value="{$data.BossName}"> 
                                </div>
                            </div>
                            
                            <div class="form-group row">
                                <label class="col-sm-3 control-label">纳税人识别号</label>
                                <div class="col-sm-8">
                                    <input id="TaxNO" name="TaxNO" class="form-control" type="text" aria-required="true" aria-invalid="true" class="error" value="{$data['TaxNO']}">
                                </div>
                            </div>
                            
                            <div class="form-group row">
                                <label class="col-sm-3 control-label">地址</label>
                                <div class="col-sm-8">
                                    <input id="Address" name="Address" class="form-control" type="text" aria-required="true" aria-invalid="true" class="error" value="{$data['Address']}">
                                </div>
                            </div>
                            
                            <div class="form-group row">
                                <label class="col-sm-3 control-label">联系电话</label>
                                <div class="col-sm-8">
                                    <input id="Phone" name="Phone" class="form-control" type="text" aria-required="true" aria-invalid="true" class="error" value="{$data['Phone']}">
                                </div>
                            </div>
                            
                            <div class="form-group row">
                                <label class="col-sm-3 control-label">传真</label>
                                <div class="col-sm-8">
                                    <input id="Fax" name="Fax" class="form-control" type="text" aria-required="true" aria-invalid="true" class="error" value="{$data['Fax']}">
                                </div>
                            </div>
                            
                            <div class="form-group row">
                                <label class="col-sm-3 control-label">电子邮件</label>
                                <div class="col-sm-8">
                                    <input id="EMail" name="EMail" class="form-control" type="text" aria-required="true" aria-invalid="true" class="error" value="{$data['EMail']}">
                                </div>
                            </div>
                            
                            <div class="form-group row">
                                <label class="col-sm-3 control-label">开户银行</label>
                                <div class="col-sm-8">
                                    <input id="Bank" name="Bank" class="form-control" type="text" aria-required="true" aria-invalid="true" class="error" value="{$data['Bank']}">
                                </div>
                            </div>
                            
							<div class="form-group row">
                                <label class="col-sm-3 control-label">银行账户名称</label>
                                <div class="col-sm-8">
                                    <input id="BankName" name="BankName" class="form-control" type="text" aria-required="true" aria-invalid="true" class="error" value="{$data['BankName']}">
                                </div>
                            </div>
                            
                            <div class="form-group row">
                                <label class="col-sm-3 control-label">银行帐号</label>
                                <div class="col-sm-8">
                                    <input id="BankNO" name="BankNO" class="form-control" type="text" aria-required="true" aria-invalid="true" class="error" value="{$data['BankNO']}">
                                </div>
                            </div>
                            
							<div class="form-group row">
                                <label class="col-sm-3 control-label">工作职责</label>
                                <div class="col-sm-8">
                                    <textarea id="JobDuty" name="JobDuty" class="form-control diff-textarea" rows="6">{$data['JobDuty']}</textarea>
                                </div>
                            </div>
                            
                            <div class="form-group row">
                                <label class="col-sm-3 control-label">备注</label>
                                <div class="col-sm-8">
                                    <textarea id="Remark" name="Remark" class="form-control diff-textarea" rows="6">{$data['Remark']}</textarea>
                                </div>
                            </div>
                            
                            <div class="form-group row">
                                <label class="col-sm-3 control-label">排序号</label>
                                <div class="col-sm-8">
                                    <input id="OrderNO" name="OrderNO" class="form-control" type="number" aria-required="true" aria-invalid="true" class="error" value="{$data['OrderNO']}">
                                </div>
                            </div>
                            
                            <div class="form-group row">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <button class="btn btn-primary" type="submit">保存</button>
                                    <a class="btn btn-white" href="javascript:history.back(-1);">返回</a>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

	<script src="__ROOT__/Public/Admin/js/jquery.min.js"></script>
	<script src="__ROOT__/Public/Admin/js/bootstrap.min.js"></script>
	<script src="__ROOT__/Public/Admin/js/plugins/layer/laydate/laydate.js"></script>
	<script src="__ROOT__/Public/Admin/js/plugins/validate/jquery.validate.min.js"></script>
	<script src="__ROOT__/Public/Admin/js/ajaxForm.js"></script>
	<script src="__ROOT__/Public/Admin/js/plugins/sweetalert/sweetalert.min.js"></script>
	
	<link href="__ROOT__/Public/Admin/css/selector/selectorstyle.css" rel="stylesheet"/>
	<script src="__ROOT__/Public/Admin/js/plugins/selector/selector.js"></script>
 	<script src="__ROOT__/Public/Admin/js/plugins/selector/jquery.ztree.all.js"></script>
 	
    <script type="text/javascript">
    $(document).ready(function () {
    	
    	$.validator.addMethod("isPhone", function (value, element) {
            var phone = /^1[34578]\d{9}$/;
            return phone.test(value);
        }, "请输入正确的手机号码");
        
        
	    var icon = "<i class='fa fa-times-circle'></i> ";
	    var form = $('form.js-ajax-forms');
	    var formloading = false;
	    //表单验证开始
	    form.validate({
	        //验证规则
	        rules: {
	            Name: {
	                required: true
	            }
	        },
	        //验证未通过提示消息
	        messages: {
	            Name:{
	                required: icon + "请输入部门名称"
	            }
	            
	        },
	        //验证通过，提交表单
	        submitHandler : function(forms) {
	            if (formloading)
	                return;
	            if($("#BossName").val() == ""){
	            	$("#BossID").val("");
	            }
	            $(forms).ajaxSubmit({
	                url : form.attr('action'), //按钮上是否自定义提交地址(多按钮情况)
	                dataType : 'json',
	                beforeSubmit : function(arr, $form, options) {
	                    formloading = true;
	                },
	                success : function(data, statusText, xhr, $form) {
	                    formloading = false;
	                    if (data.status) {
	                        //添加成功
	                        swal({
	                            title: "继续操作？",
	                            text: "操作成功！",
	                            type: "success",
	                            showCancelButton: true,
	                            confirmButtonColor: "#DD6B55",
	                            confirmButtonText: "确认",
	                            cancelButtonText: "返回",
	                            closeOnConfirm: false,
	                            closeOnCancel: false
	                        },
	                        function (isConfirm) {
	                            if (isConfirm) {
	                                document.location.reload();
	                            } else {
	                                document.location.href = "{:U('Organization/index')}";
	                                return true;
	                            }
	                        }); 
	                    } else {
	                        swal("操作失败", data.info, "error");
	                    }
	                }
	            });
	        }
	    });
	 });
	 
	<if condition="$update"> console.info("下拉树！"); </if>
	  
    </script>
</body>
</html>